<form action="index.php" method="post" name="adminForm">
<script>
  jQuery(document).ready(
    function(){
      create_tab("#tabs");
      jQuery(".tablesorter").tablesorter({sortList: [[1,1],[2,1],[3,1],[0,0]]}); 
      show_table_partial("#table_stat");
      jQuery("#table_stat a").click();
    }
  );
</script>

<?  $divisions = array();
  if(isset($this->divisions))
    $divisions = $this->divisions;
?>
<div id="tabs" style="padding-top:10px;">
  <ul>
<?  foreach($divisions as $division_id => $division): ?>
    <li>
      <a <?= $division_id == $this->division_id ? 'class="active"' : ''?> href="<?= JRoute::_('index.php?option=com_pbny&controller=stats&task=display&id='.$this->season_id.
                  '&others='.$division_id)?>">
        <?= $division ?>
      </a>
    </li>
<?  endforeach; ?>
  </ul>
</div>

<?  $categories = array('points' => 'POINTS', 'rebounds' => 'REBOUNDS', 
                        'assists' => 'ASSISTS', 'steals' => 'STEALS', 'blocks' => 'BLOCKS'); ?>
<div id="tabs" style="padding-top:10px;">
  <ul>
<?  foreach($categories as $k => $c): ?>
    <li>
      <a <?= $k == $this->view_type ? 'class="active"' : ''?> href="<?= JRoute::_('index.php?option=com_pbny&controller=stats&task=display&id='.$this->season_id.
                  '&others='.$this->division_id.
                  '&others2='.$k)?>" >
        <?= $c ?>
      </a>
    </li>
<?  endforeach; ?>
  </ul>
</div>

<h3 style="padding:10px 10px">ASSISTS LEADERS</h3>
<table style="width:100%">
  <tr>
<?  $count = 0;
  foreach($this->top_assists as $player_id => $assists){
    if($count == 3 || $assists == 0)
      break;
    $count++;
      $player = $this->players[$player_id] ?>
    <td width="33%">
      <table style="width:100%;">
        <tr>
          <td width="150px">
            <img src="<?= JURI::root( true ).$player->pic->pic?>" style="width:150px; height:150px;">
          </td>
          <td valign="middle" style="text-align:center;">
            <h3><?= $player->fullname ?></h3>
            <br />
            <h2><?= $assists ?></h2>
          </td>
        </tr>
      </table>
    </td>
<?  }?>
  </tr>
</table>

<div id="table_stat">
<table style="width:100%; margin:20px auto;" class="tablesorter">
  <thead>
    <tr>
      <th class="cell_key">Player</th>
      <th class="cell_key">GP</th>
      <th class="cell_key">AST</th>
      <th class="cell_key">ASPG</th>
    </tr>
  </thead>
  <tbody>
<?
    $fields = array('games_played', 'assists', 'avg_assists');
    foreach(array_keys($this->top_assists) as $player_id){
      $player = $this->players[$player_id];
      foreach($fields as $f){
        if(isset($player->player_game_stat[$f]))
          $player->$f = $player->player_game_stat[$f];
        else
          $player->$f = 0;
      }
?>
      <tr>
        <td class="cell_value"><?= $player->fullname?></td>
        <td class="cell_value"><?= $player->games_played ?></td>
        <td class="cell_value"><?= $player->assists?></td>
        <td class="cell_value"><?= $player->avg_assists?></td>
      </tr>
<?    }
?>
  </tbody>
</table>
<a href="" style="margin-left:900px">Show All</a>
</div>
</form>
